﻿
@{
    Layout = null;
    Double modelPrice = 0;
    Double modelTotal = 0;
    int modelCount = 0;
    String modelKind = "";
    int modelStyle = 0;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>云瑞家庭农场</title>
    <link rel="shortcut icon" href="~/Content/assets/i/miemie_favicon.ico" />
    <link href="~/Content/layui/css/layui.css" rel="stylesheet" />
    <script src="~/Content/layui/layui.js"></script>
    <script type="text/javascript" src="/Scripts/jquery-3.3.1.js"></script>
    <script type="text/javascript">
        
        layui.use(['form', 'layedit', 'laydate'], function () {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate;
            

            //创建一个编辑器
            var editIndex = layedit.build('LAY_demo_editor');

            $(document).ready(function () {
                var _token = cookie("token");
                var Private = false;
                $.ajax({
                    url: "/YunRuiFarmAPI/GoatAppointmentGetLoginMessageAPI", //请求的URL
                    cache: true, //不从缓存中取数据
                    data: {
                        "Token": _token,
                    }, //发送的参数
                    type: 'post', //请求类型
                    dataType: 'json', //返回类型是JSON
                    timeout: 20000, //超时
                })
                    .done(function (result) {
                        if (result.IsSuccess) {
                            $("#Name").html("<img src= \"/Content/image/小埋1.jpg\" class=\"layui-nav-img\"/>" + result.Name);
                        }
                        else {
                            $("#Name").html("<img src= \"/Content/image/小埋1.jpg\" class=\"layui-nav-img\"/>" + "请先登录")
                            $("#UsecCenter").html("<dd><a href=\"/YunRuiFarm/Login\">登录</a></dd>");
                            $("#Operation").html("");
                        }
                    });
                

                //清除cookie
                $("#Cancellation").click(function () {
                    layer.msg("清除token");
                    delcookie("token", "", { expires: -1 });
                    window.location.href = "/YunRuiFarm/Restaurant";
                });
                //点击左侧导航预约进行cookie判断
                $("#power").click(function () {
                    $.ajax({
                        url: "/YunRuiFarmAPI/GetAdministratorsPower", //请求的URL
                        cache: true, //不从缓存中取数据
                        data: {
                            "Token": _token
                        }, //发送的参数
                        type: 'post', //请求类型
                        dataType: 'json', //返回类型是JSON
                        timeout: 20000, //超时
                        error: function (xhr, err) {

                        },
                        success: function (result) {
                            if (result.IsSuccess)
                                window.location.href = result.Message;

                        }
                    })
                });

            });
            var now = new Date()
            var NowTime = now.getFullYear() + "-" + (now.getMonth() + 1 < 10 ? '0' : '') + (now.getMonth() + 1) + "-" + (now.getDate() + 1 < 10 ? '0' : '') + (now.getDate() + 1);
            GetMessage(NowTime);
            function getQueryString(name) {
                var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
                var r = window.location.search.substr(1).match(reg);
                if (r != null) {
                    return unescape(r[2]);
                }
                return 1;
            }

            function cookie(key, value, options) {
                if (typeof value === "undefined") {
                    var cookies = document.cookie.split("; ");
                    for (var i = 0, len = cookies.length; i < len; i++) {
                        var cookie = cookies[i].split("=");
                        if (decodeURIComponent(cookie[0]) === key) {
                            return decodeURIComponent(cookie[1]);
                        }
                    }
                    return null;
                }
            }
            //删除cookie
            function delcookie(key, value, options) {
                options = options || {};
                var cookie = encodeURIComponent(key) + "=" + value;
                if ((typeof options.expires) !== "undefined") {
                    if (typeof options.expires === "number") {
                        var days = options.expires,
                            t = options.expires = new Date();
                        t.setDate(t.getDate() + days);
                    }
                    cookie += ";expires=" + options.expires.toUTCString();
                }
                if (typeof options.path !== "undefined")
                    cookie += ";path=" + options.path;
                if (typeof options.domain !== "undefined")
                    cookie += ";domain=" + options.domain;
                if (options.secure)
                    cookie += ";secure";
                document.cookie = cookie;
            }
            
            function GetMessage(NowTime){
                $.ajax({
                    url: "/YunRuiFarmAPI/GetRestaurantMessageAPI", //请求的URL
                    cache: true, //不从缓存中取数据
                    data: {
                        "NowTime": NowTime,
                    },
                    type: 'post', //请求类型
                    dataType: 'json', //返回类型是JSON
                    timeout: 20000, //超时
                    error: function (xhr, err) {
                        alert("获取失败");
                    },
                    success: function (result) {
                        var number = 0;
                        var wait = 0;
                        var order = "可预约";
                        Private = false;
                        if (result.Data.length != 0) {
                            for (var i = 0; i < result.Data.length; i++) {
                                if (result.Data[i].Result=="预约成功")
                                    number += result.Data[i].Number;
                                else
                                    wait += result.Data[i].Number;
                                if (result.Data[i].Private == true && result.Data[i].Result == "预约成功") {
                                    Private = true;
                                    order = "已被包场";
                                }
                            }
                            if (number >=10)
                                order = "接待人数较多";
                        }
                        $("#Reception").html("今日已接待：" + number + "人次&emsp;&emsp;&emsp;排队预约中："+wait+"人次<br />当前状态：" + order);

                    }
                })
                
            }
            
            laydate.render({
                elem: '#datatable'
                , value: NowTime
                , done: function (value, date) {
                    GetMessage(value);  
                }
                , theme: '#393D49'
                , min: 1
            });
            layui.use('layer', function () { //独立版的layer无需执行这一句
                var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
                var _token = cookie("token");
                $.ajax({
                    url: "/YunRuiFarmAPI/GoatAppointmentGetLoginMessageAPI", //请求的URL
                    cache: true, //不从缓存中取数据
                    data: {
                        "Token": _token,
                    }, //发送的参数
                    type: 'post', //请求类型
                    dataType: 'json', //返回类型是JSON
                    timeout: 20000, //超时
                })
                    .done(function (result) {
                        var modelName = "";
                        var modelContacts = "";
                        if (result.IsSuccess) {
                            modelName = result.Name;
                            modelContacts = result.Contacts;
                        }
                        str = "<div style=\"padding: 50px; line-height: 22px; background-color: #393D49; color:#fff; font-weight: 400;\">"
                            + " <div class=\"layui- inline\" style=\"\">"
                            + " <label class=\"layui-form-label\" style-\"\"> 联系人</label >"
                            + "<div class=\"layui-input-inline\">"
                            + "<input type=\"tel\" name=\"fullname\" lay- verify=\"fullname\" autocomplete= \"off\" class=\"layui-input\" id= \"name\" value=\"" + modelName + "\"> "
                            + "</div>"
                            + "</div>"
                            + "<div class=\"layui- inline\" style=\"\">"
                            + "<label class=\"layui-form-label\" style-\"\"> 联系方式</label >"
                            + "<div class=\"layui-input-inline\">"
                            + "<input type=\"tel\" name=\"fullname\" lay- verify=\"fullname\" autocomplete= \"off\" class=\"layui-input\" id= \"contacts\" value=\"" + modelContacts + "\"> "
                            + "</div>"
                            + "</div>"
                            + "<div class=\"layui- inline\" style=\"\">"
                            + "<label class=\"layui-form-label\" style-\"\"> 预约人数</label >"
                            + "<div class=\"layui-input-inline\">"
                            + "<button class=\"layui-icon\" style=\"float:left; height:38px; width:20px;\" id=\"Reduce\">&#xe603;</button>"
                            + "<input type=\"tel\" name=\"fullname\" lay-verify=\"fullname\" autocomplete=\"off\" class=\"layui-input\" id=\"number\" readonly=\"readonly\" style=\"width:18%;float:left; text-align:center;\" value=\"1\">"
                            + "<button class=\"layui-icon\" style=\"float:left; height:38px; width:20px;\" id=\"Add\">&#xe602;</button>"
                            + "</div>"
                            + "</div>"
                            + "<div class=\"layui-inline\" style=\"\">"
                            + "<label class=\"layui-form-label\" style-\"\"> 预约日期</label >"
                            + "<div class=\"layui-input-inline\">"
                            + "<input type=\"tel\" name=\"fullname\" lay-verify=\"fullname\" autocomplete= \"off\" class=\"layui-input\" id= \"date\" readonly=\"readonly\" value=\"" + $("#datatable")[0].value + "\"> "
                            + "</div>"
                            + "</div>"
                            + "<form class=\"layui-form\" action=\"\">"
                            + "<div class=\"layui- inline\" style=\"\">"
                                + "<label class=\"layui-form-label\" style-\"\"> 预约时间段</label >"
                                + "<div class=\"layui-input-block\">"
                                    + "<input type=\"radio\" name=\"Time\" value=\"上午\" title=\"上午\" checked=\"\">"
                                    + "<input type=\"radio\" name=\"Time\" value=\"下午\" title=\"下午\">"
                                    + "<input type=\"radio\" name=\"Time\" value=\"全天\" title=\"全天\">"
                                + "</div>"
                            + "</div>"
                            + "<div class=\"layui-form-item\">"
                            + "<label class=\"layui-form-label\" style-\"\"> 是否包场(不会收取额外费用)</label >"
                            + "<div class=\"layui-input-block\">"
                            + "<input type=\"radio\" name=\"Private\" value=\"false\" title=\"不包场\" checked=\"\">"
                            + "<input type=\"radio\" name=\"Private\" value=\"true\" title=\"包场\">"
                            + "</div>"
                            + "</div>"
                            + "<div class=\"layui-form-item\">"
                            + "<label class=\"layui-form-label\">活动内容</label>"
                            + "<div class=\"layui-input-block\">"
                            + "<input type=\"checkbox\" name=\"activity\" value=\"就餐\" title=\"就餐\">"
                            + "<input type=\"checkbox\" name=\"activity\" value=\"住宿\" title=\"住宿\">"
                            + "<input type=\"checkbox\" name=\"activity\" value=\"郊游\" title=\"郊游\">"
                            + "</div>"
                            + "</div>"
                            + "<div class=\"layui-form-item\">"
                            + "<label class=\"layui-form-label\">餐饮选择</label>"
                            + "<div class=\"layui-input-block\">"
                            + "<input type=\"checkbox\" name=\"restaurant\" value=\"农家特色烧烤\" title=\"农家特色烧烤\">"
                            + "<input type=\"checkbox\" name=\"restaurant\" value=\"农家特色菜肴\" title=\"农家特色菜肴\">"
                            + "</div>"
                            + "</div>"
                            + "</form>"
                            + " <div class=\"layui- inline\" style=\"\">"
                            + " <label class=\"layui-form-label\" style-\"\"> 备注</label >"
                            + "<div class=\"layui-input-inline\">"
                            + "<input type=\"tel\" name=\"fullname\" lay- verify=\"fullname\" autocomplete= \"off\" class=\"layui-input\" placeholder=\"如有其他需要的请留言\" id= \"remarks\"> "
                            + "</div>"
                            + "</div>"
                            + " <div class=\"layui- inline\" style=\"margin-top:10px\">"
                            + "<a href=\"/母成羊认养协议.html\" target=\"_blank\" style=\"color:white;;margin-left:20%\">具体收费信息请点击查看</a>";
                            + "</div> "
                            + "</div> ";
                    });
                
                //触发事件
                var active = {
                    notice: function () {
                        //示范一个公告层
                        layer.open({
                            type: 1
                            , title: false //不显示标题栏
                            , closeBtn: false
                            , area: '600px;'
                            , shade: 0.8
                            , id: 'LAY_layuipro' //设定一个id，防止重复弹出
                            , btn: ['确认预约', '暂不预约']
                            , btnAlign: 'c'
                            , moveType: 1 //拖拽模式，0或者1
                            , content: str
                            , success: function (layero) {
                                form.render();//重新渲染form
                                var btn = layero.find('.layui-layer-btn');
                                btn.find('.layui-layer-btn0').attr({
                                    load: Appointment
                                    , target: '_blank'
                                });
                            }
                        });
                    }
                };

                $('#layerDemo .layui-btn').on('click', function () {
                    var othis = $(this), method = othis.data('method');
                    active[method] ? active[method].call(this, othis) : '';
                });
                function Appointment() {
                    //预约
                    var _token = cookie("token");

                    $("#date")[0].value = $("#datatable")[0].value;
                    $("#Reduce").click(function () {
                        if ($('#number').val() > 2) {
                            $('#number').val(parseInt($('#number').val()) - 1);
                        }
                    });
                    $("#Add").click(function () {
                        if (parseInt($('#number').val()) < 20) {
                            $('#number').val(parseInt($('#number').val()) + 1);
                        }
                    });
                    
                    $(".layui-layer-btn0").click(function () {
                        var Activity = "";
                        var Restaurant = "";
                        for (var i = 0; i < $("input[name='activity']:checked").length; i++) {
                            Activity += $("input[name='activity']:checked")[i].value
                            if (i != $("input[name='activity']:checked").length - 1)
                                Activity += ",";
                        }
                        for (var i = 0; i < $("input[name='restaurant']:checked").length; i++) {
                            Restaurant += $("input[name='restaurant']:checked")[i].value
                            if (i != $("input[name='restaurant']:checked").length - 1)
                                Restaurant += ",";
                        }
                        $.ajax({
                            url: "/YunRuiFarmAPI/RestaurantAppointmentAPI", //请求的URL
                            cache: true, //不从缓存中取数据
                            data: {
                                "name": $("#name")[0].value,
                                "contacts": $("#contacts")[0].value,
                                "number": parseInt($('#number').val()),
                                "date": $("#date")[0].value,
                                "time": $("input[name='Time']:checked")[0].value,
                                "Private": $("input[name='Private']:checked")[0].value,
                                "remarks": $("#remarks")[0].value,
                                "Activity": Activity,
                                "Restaurant": Restaurant,
                                "Token": _token
                            }, //发送的参数
                            type: 'post', //请求类型
                            dataType: 'json', //返回类型是JSON
                            timeout: 20000, //超时
                            error: function (xhr, err) {
                                alert(Activity);
                            },
                            success: function (result) {
                                if (result.Message == "未获取到token") {
                                    layer.msg("请先登录");
                                    setTimeout(function () {
                                        window.location.href = '/YunRuiFarm/Login'
                                    }, 3000);
                                }
                                else
                                    layer.msg(result.Message);
                            }
                        })
                    });



                }
            });
        });
        
    </script>
    <script>
        layui.use('element', function () {
            var element = layui.element;
        });
        var url = document.location.toString();
        var arrUrl = url.split("=");
        var para = arrUrl[1];


    </script>
    <style>
        body {
            font-size: 18px;
        }



        #content-top {
            width: 98%;
            height:56%;
            float: right;
            margin-right: 1%;
            margin-top: 1%;
            margin-bottom: 1%;
            background-color: rgba(255,255,255,0.5);
        }

        #content-bottom {
            width: 98%;
            height: 30%;
            float: right;
            margin-right: 1%;
            margin-bottom: 1%;
            background-color: rgba(255,255,255,0.5);
        }
        #content-top-img {
            width: 48%;
            height: 95%;
            float: left;
            margin-left: 1%;
            margin-top: 1%;
            margin-bottom: 1%;
        }
        #content-top-message {
            width: 50%;
            height: 95%;
            float: left;
            margin-left: 1%;
            margin-top: 1%;
            margin-bottom: 1%;
        }
        img {
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body class="layui-layout-body">
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header" style="width:auto">
            <div class="layui-logo" style=" background-image: url('../../Content/image/logo.jpg');background-size:100% 100%;"></div>
            <!-- 头部区域（可配合layui已有的水平导航） -->
            <ul class="layui-nav layui-layout-left" style="font-size: 20px;">
                <li class="layui-nav-item"><a href="/YunRuiFarm/Index">首页</a></li>
                <li class="layui-nav-item"><a href="/YunRuiFarm/Adopt">羊领养预约</a></li>
                <li class="layui-nav-item"><a href="/YunRuiFarm/Agricultural">农副产品预约</a></li>
                <li class="layui-nav-item"><a href="/YunRuiFarm/Restaurant">餐饮预约</a></li>
            </ul>
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item">
                    <a href="javascript:;" id="Name">
                        <img src="/Content/image/小埋1.jpg" class="layui-nav-img" />请先登录
                    </a>
                    <dl class="layui-nav-child" id="UsecCenter">
                        <dd><a href="/YunRuiFarm/UserInfo">基本资料</a></dd>
                        <dd><a href="/YunRuiFarm/UserGoatOrder">我的订单</a></dd>
                        <dd><a href="/YunRuiFarm/UserFeedback">反馈信息</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item" id="Operation">
                    <a href="javascript:;">账户操作</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" id="power">切换到管理员</a></dd>
                        <dd><a href="javascript:;" id="Cancellation">注销</a></dd>
                    </dl>
                </li>
            </ul>
        </div>
        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
                <ul class="layui-nav layui-nav-tree" lay-filter="test">
                    <li class="layui-nav-item layui-nav-itemed">
                        <a class="" href="javascript:;">餐饮</a>
                        <dl class="layui-nav-child">
                            <dd><a href="/YunRuiFarm/Restaurant">餐饮预约</a></dd>
                            <dd><a href="javascript:;">我的订单</a></dd>
                        </dl>
                    </li>
                </ul>
            </div>
        </div>
        <div class="layui-body" style="height:100%;background-image: url('../../Content/image/grass.jpg');background-repeat:no-repeat; background-attachment: fixed;background-size:100%">
            <!-- 内容主体区域 -->
            <div id="content-top">
                <div id="content-top-img">
                    <img src="~/Content/image/餐饮/预约展示.jpg" />
                </div>
                <div id="content-top-message">
                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 0px;">
                        <legend>云瑞家庭农场餐饮预约</legend>
                    </fieldset>
                    <blockquote class="layui-elem-quote layui-quote-nm" style="width: 92%;height:40%;float:left;" id="shanyang">
                        本网站仅提供预约服务，费用在预约当天到达农场后结算<br>
                        农庄提供自助野营、自助烧烤、农场自耕，农家私人厨房，等体现浓郁乡间风情的活动！<br>
                        农庄房间均带独立卫生间、空调、数字电视、24小时热水、无线网络等配套设施。<br>
                        收费项目请点击预约进行查询<br>
                    </blockquote>
                    <blockquote class="layui-elem-quote layui-quote-nm" style="width: 92%;height:10%;float:left;" id="Reception">
                        今日已接待：0人次&emsp;&emsp;&emsp;排队预约中：0人次<br />
                        当前状态：可预约
                    </blockquote>
                    <b style="float:left;margin-top:5px">请选择日期：</b>
                    <div class="layui-input-inline" style="float:left">
                        <input type="text" class="layui-input" id="datatable" placeholder="yyyy-MM-dd">
                    </div>
                    <div class="site-demo-button" id="layerDemo" style="margin-bottom: 0;margin-top:5%">
                        <button class="layui-btn" data-method="notice" style="float:left;margin-left:10%;margin-bottom:5%;">预约</button>
                    </div>
                </div>
            </div>
            <div id="content-bottom">
                <blockquote class="layui-elem-quote layui-quote-nm" style="width: 97%;float:left;" id="shanyang">
                    &emsp;宁波云瑞家庭农场位于横街镇毛岙猫山头村，众山环绕，​‌‌风景怡人，品味一种幽雅与宁静的山乡韵味。<br>
                    &emsp;提供自助野营、自助烧烤、农场自耕，农家私人厨房，等体现浓郁的乡情,深厚的爱意！！<br>
                    &emsp;农庄房间均带独立卫生间、空调、数字电视、24小时热水、无线网络等配套设施，现已能接待游客100多人。
                    在这里您将徜徉在神山秀水间，品尝绿色纯正的农家饭菜，还可以购买到正宗的本地特产，笋干，山货，绿色蔬菜等农家特产。
                    宁波云瑞家庭农场是一个“天然氧吧”，在该村内居住一天，吸入的负氧离子相当于居住在城市一年是休闲养生的好去处。云瑞农场让你愉快的来，愉悦的回！
                </blockquote>
            </div>
        </div>

        <script>
            
        </script>
</body>
</html>
